<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-04 16:53:56
 * @LastEditTime: 2023-06-28 16:16:15
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Http\Services\BaseData;

use App\Http\Services\Service;
use App\Repositories\CurrencyRepository;

use Illuminate\Support\Facades\DB;

/**
 * @property CurrencyRepository $repository
 */
class CurrencyService extends Service
    {

    public function __construct(CurrencyRepository $repository)
        {
        $this->repository = $repository;
        }

    public function list()
        {
        $data = $this->repository->condition(request())->getGrid();
        return $data;
        }
    protected function save($request)
        {
        // DB::enableQueryLog();
        // dd(DB::getQueryLog());
        return $this->repository->autosave($request->toArray());
        }
    protected function delete()
        {
        return $this->repository->whereIn("id", $this->getRequestIds())->get()->filter(function ($item)
            {
            if ($item->issystem == 1) {
                fail("系统默认，禁止删除", 500);
                }
            $item->delete();
            });
        }

    }